
function *gen() {
  yield 1;
  yield 2;
  yield 3;
}

let it = gen()

let r1 = it.next()
console.log(r1)

let r2 = it.next()
console.log(r2)

// it.return('直接结果 saga') // 提前让 saga 结束

try {
  it.throw('执行出错了') // 通过抛出一个错误也可以提前让 saga 结束
} catch(e) {
  console.log(e, '---')
}

let r3 = it.next()
console.log(r3)

let r4 = it.next()
console.log(r4)

